package com.tjp.eight.ui.fragment.forgetpass;

import com.tjp.eight.AllRetrofit;
import com.tjp.eight.ResultModel;
import com.tjp.eight.base.BasePresenterImpl;
import com.tjp.eight.constant.UrlConstant;
import com.tjp.eight.net.NetCallBack;
import com.tjp.eight.net.SubscribeCallBack;
import com.tjp.eight.ui.fragment.setpassword.SetPassModel;
import com.tjp.eight.utils.AppUtils;

import okhttp3.RequestBody;

/**
 * Created by Administrator on 2017/3/28.
 */
public class FortGetPassPresenter extends BasePresenterImpl<FGpassView> {
    private FortGetPassService service = AllRetrofit.getRetrofit(UrlConstant.BaseUrl).create(FortGetPassService.class);
    public FortGetPassPresenter(FGpassView view) {
        attachView(view);
    }

    public void getMsgCode(String mcJson) {
        RequestBody body = AppUtils.getRequestBody(mcJson);
        addSubscription(service.getMsgCode(body), new SubscribeCallBack<>(new NetCallBack<ResultModel>() {
            @Override
            public void onSuccess(ResultModel model) {
                view.sendSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {

            }

            @Override
            public void onCompleted() {

            }
        }));
    }
    public void setPass(String mcJson) {
        RequestBody body = AppUtils.getRequestBody(mcJson);
        addSubscription(service.setPass(body), new SubscribeCallBack<>(new NetCallBack<SetPassModel>() {
            @Override
            public void onSuccess(SetPassModel model) {
                view.setPassSuccess(model);
            }

            @Override
            public void onFails(int code, String msg) {

            }

            @Override
            public void onCompleted() {

            }
        }));
    }
}
